{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 模型训练"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>instant</th>\n",
       "      <th>season_1</th>\n",
       "      <th>season_2</th>\n",
       "      <th>season_3</th>\n",
       "      <th>season_4</th>\n",
       "      <th>mnth_1</th>\n",
       "      <th>mnth_2</th>\n",
       "      <th>mnth_3</th>\n",
       "      <th>mnth_4</th>\n",
       "      <th>mnth_5</th>\n",
       "      <th>...</th>\n",
       "      <th>weekday_5</th>\n",
       "      <th>weekday_6</th>\n",
       "      <th>temp</th>\n",
       "      <th>atemp</th>\n",
       "      <th>hum</th>\n",
       "      <th>windspeed</th>\n",
       "      <th>holiday</th>\n",
       "      <th>workingday</th>\n",
       "      <th>yr</th>\n",
       "      <th>cnt</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.355170</td>\n",
       "      <td>0.373517</td>\n",
       "      <td>0.828620</td>\n",
       "      <td>0.284606</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>985</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.379232</td>\n",
       "      <td>0.360541</td>\n",
       "      <td>0.715771</td>\n",
       "      <td>0.466215</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>801</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.171000</td>\n",
       "      <td>0.144830</td>\n",
       "      <td>0.449638</td>\n",
       "      <td>0.465740</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1349</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.175530</td>\n",
       "      <td>0.174649</td>\n",
       "      <td>0.607131</td>\n",
       "      <td>0.284297</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1562</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.209120</td>\n",
       "      <td>0.197158</td>\n",
       "      <td>0.449313</td>\n",
       "      <td>0.339143</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1600</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 35 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "   instant  season_1  season_2  season_3  season_4  mnth_1  mnth_2  mnth_3  \\\n",
       "0        1         1         0         0         0       1       0       0   \n",
       "1        2         1         0         0         0       1       0       0   \n",
       "2        3         1         0         0         0       1       0       0   \n",
       "3        4         1         0         0         0       1       0       0   \n",
       "4        5         1         0         0         0       1       0       0   \n",
       "\n",
       "   mnth_4  mnth_5  ...  weekday_5  weekday_6      temp     atemp       hum  \\\n",
       "0       0       0  ...          0          1  0.355170  0.373517  0.828620   \n",
       "1       0       0  ...          0          0  0.379232  0.360541  0.715771   \n",
       "2       0       0  ...          0          0  0.171000  0.144830  0.449638   \n",
       "3       0       0  ...          0          0  0.175530  0.174649  0.607131   \n",
       "4       0       0  ...          0          0  0.209120  0.197158  0.449313   \n",
       "\n",
       "   windspeed  holiday  workingday  yr   cnt  \n",
       "0   0.284606        0           0   0   985  \n",
       "1   0.466215        0           0   0   801  \n",
       "2   0.465740        0           1   0  1349  \n",
       "3   0.284297        0           1   0  1562  \n",
       "4   0.339143        0           1   0  1600  \n",
       "\n",
       "[5 rows x 35 columns]"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "df = pd.read_csv('./FE_day.csv')\n",
    "df.head()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>instant</th>\n",
       "      <th>season_1</th>\n",
       "      <th>season_2</th>\n",
       "      <th>season_3</th>\n",
       "      <th>season_4</th>\n",
       "      <th>mnth_1</th>\n",
       "      <th>mnth_2</th>\n",
       "      <th>mnth_3</th>\n",
       "      <th>mnth_4</th>\n",
       "      <th>mnth_5</th>\n",
       "      <th>...</th>\n",
       "      <th>weekday_5</th>\n",
       "      <th>weekday_6</th>\n",
       "      <th>temp</th>\n",
       "      <th>atemp</th>\n",
       "      <th>hum</th>\n",
       "      <th>windspeed</th>\n",
       "      <th>holiday</th>\n",
       "      <th>workingday</th>\n",
       "      <th>yr</th>\n",
       "      <th>cnt</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td>731.000000</td>\n",
       "      <td>731.000000</td>\n",
       "      <td>731.000000</td>\n",
       "      <td>731.000000</td>\n",
       "      <td>731.000000</td>\n",
       "      <td>731.000000</td>\n",
       "      <td>731.000000</td>\n",
       "      <td>731.000000</td>\n",
       "      <td>731.000000</td>\n",
       "      <td>731.000000</td>\n",
       "      <td>...</td>\n",
       "      <td>731.000000</td>\n",
       "      <td>731.000000</td>\n",
       "      <td>731.000000</td>\n",
       "      <td>731.000000</td>\n",
       "      <td>731.000000</td>\n",
       "      <td>731.000000</td>\n",
       "      <td>731.000000</td>\n",
       "      <td>731.000000</td>\n",
       "      <td>731.000000</td>\n",
       "      <td>731.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mean</th>\n",
       "      <td>366.000000</td>\n",
       "      <td>0.247606</td>\n",
       "      <td>0.251710</td>\n",
       "      <td>0.257182</td>\n",
       "      <td>0.243502</td>\n",
       "      <td>0.084815</td>\n",
       "      <td>0.077975</td>\n",
       "      <td>0.084815</td>\n",
       "      <td>0.082079</td>\n",
       "      <td>0.084815</td>\n",
       "      <td>...</td>\n",
       "      <td>0.142271</td>\n",
       "      <td>0.143639</td>\n",
       "      <td>0.543594</td>\n",
       "      <td>0.518864</td>\n",
       "      <td>0.645649</td>\n",
       "      <td>0.346536</td>\n",
       "      <td>0.028728</td>\n",
       "      <td>0.683995</td>\n",
       "      <td>0.500684</td>\n",
       "      <td>4504.348837</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>std</th>\n",
       "      <td>211.165812</td>\n",
       "      <td>0.431917</td>\n",
       "      <td>0.434293</td>\n",
       "      <td>0.437380</td>\n",
       "      <td>0.429489</td>\n",
       "      <td>0.278797</td>\n",
       "      <td>0.268316</td>\n",
       "      <td>0.278797</td>\n",
       "      <td>0.274674</td>\n",
       "      <td>0.278797</td>\n",
       "      <td>...</td>\n",
       "      <td>0.349567</td>\n",
       "      <td>0.350963</td>\n",
       "      <td>0.228091</td>\n",
       "      <td>0.213909</td>\n",
       "      <td>0.146457</td>\n",
       "      <td>0.159766</td>\n",
       "      <td>0.167155</td>\n",
       "      <td>0.465233</td>\n",
       "      <td>0.500342</td>\n",
       "      <td>1937.211452</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>min</th>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>...</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>22.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25%</th>\n",
       "      <td>183.500000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>...</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.346343</td>\n",
       "      <td>0.339674</td>\n",
       "      <td>0.534704</td>\n",
       "      <td>0.232045</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>3152.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50%</th>\n",
       "      <td>366.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>...</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.547268</td>\n",
       "      <td>0.535113</td>\n",
       "      <td>0.644388</td>\n",
       "      <td>0.326928</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>4548.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75%</th>\n",
       "      <td>548.500000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>...</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.743002</td>\n",
       "      <td>0.695083</td>\n",
       "      <td>0.750857</td>\n",
       "      <td>0.434622</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>5956.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>max</th>\n",
       "      <td>731.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>...</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>8714.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>8 rows × 35 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "          instant    season_1    season_2    season_3    season_4      mnth_1  \\\n",
       "count  731.000000  731.000000  731.000000  731.000000  731.000000  731.000000   \n",
       "mean   366.000000    0.247606    0.251710    0.257182    0.243502    0.084815   \n",
       "std    211.165812    0.431917    0.434293    0.437380    0.429489    0.278797   \n",
       "min      1.000000    0.000000    0.000000    0.000000    0.000000    0.000000   \n",
       "25%    183.500000    0.000000    0.000000    0.000000    0.000000    0.000000   \n",
       "50%    366.000000    0.000000    0.000000    0.000000    0.000000    0.000000   \n",
       "75%    548.500000    0.000000    1.000000    1.000000    0.000000    0.000000   \n",
       "max    731.000000    1.000000    1.000000    1.000000    1.000000    1.000000   \n",
       "\n",
       "           mnth_2      mnth_3      mnth_4      mnth_5  ...   weekday_5  \\\n",
       "count  731.000000  731.000000  731.000000  731.000000  ...  731.000000   \n",
       "mean     0.077975    0.084815    0.082079    0.084815  ...    0.142271   \n",
       "std      0.268316    0.278797    0.274674    0.278797  ...    0.349567   \n",
       "min      0.000000    0.000000    0.000000    0.000000  ...    0.000000   \n",
       "25%      0.000000    0.000000    0.000000    0.000000  ...    0.000000   \n",
       "50%      0.000000    0.000000    0.000000    0.000000  ...    0.000000   \n",
       "75%      0.000000    0.000000    0.000000    0.000000  ...    0.000000   \n",
       "max      1.000000    1.000000    1.000000    1.000000  ...    1.000000   \n",
       "\n",
       "        weekday_6        temp       atemp         hum   windspeed     holiday  \\\n",
       "count  731.000000  731.000000  731.000000  731.000000  731.000000  731.000000   \n",
       "mean     0.143639    0.543594    0.518864    0.645649    0.346536    0.028728   \n",
       "std      0.350963    0.228091    0.213909    0.146457    0.159766    0.167155   \n",
       "min      0.000000    0.000000    0.000000    0.000000    0.000000    0.000000   \n",
       "25%      0.000000    0.346343    0.339674    0.534704    0.232045    0.000000   \n",
       "50%      0.000000    0.547268    0.535113    0.644388    0.326928    0.000000   \n",
       "75%      0.000000    0.743002    0.695083    0.750857    0.434622    0.000000   \n",
       "max      1.000000    1.000000    1.000000    1.000000    1.000000    1.000000   \n",
       "\n",
       "       workingday          yr          cnt  \n",
       "count  731.000000  731.000000   731.000000  \n",
       "mean     0.683995    0.500684  4504.348837  \n",
       "std      0.465233    0.500342  1937.211452  \n",
       "min      0.000000    0.000000    22.000000  \n",
       "25%      0.000000    0.000000  3152.000000  \n",
       "50%      1.000000    1.000000  4548.000000  \n",
       "75%      1.000000    1.000000  5956.000000  \n",
       "max      1.000000    1.000000  8714.000000  \n",
       "\n",
       "[8 rows x 35 columns]"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.describe()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 731 entries, 0 to 730\n",
      "Data columns (total 35 columns):\n",
      " #   Column        Non-Null Count  Dtype  \n",
      "---  ------        --------------  -----  \n",
      " 0   instant       731 non-null    int64  \n",
      " 1   season_1      731 non-null    int64  \n",
      " 2   season_2      731 non-null    int64  \n",
      " 3   season_3      731 non-null    int64  \n",
      " 4   season_4      731 non-null    int64  \n",
      " 5   mnth_1        731 non-null    int64  \n",
      " 6   mnth_2        731 non-null    int64  \n",
      " 7   mnth_3        731 non-null    int64  \n",
      " 8   mnth_4        731 non-null    int64  \n",
      " 9   mnth_5        731 non-null    int64  \n",
      " 10  mnth_6        731 non-null    int64  \n",
      " 11  mnth_7        731 non-null    int64  \n",
      " 12  mnth_8        731 non-null    int64  \n",
      " 13  mnth_9        731 non-null    int64  \n",
      " 14  mnth_10       731 non-null    int64  \n",
      " 15  mnth_11       731 non-null    int64  \n",
      " 16  mnth_12       731 non-null    int64  \n",
      " 17  weathersit_1  731 non-null    int64  \n",
      " 18  weathersit_2  731 non-null    int64  \n",
      " 19  weathersit_3  731 non-null    int64  \n",
      " 20  weekday_0     731 non-null    int64  \n",
      " 21  weekday_1     731 non-null    int64  \n",
      " 22  weekday_2     731 non-null    int64  \n",
      " 23  weekday_3     731 non-null    int64  \n",
      " 24  weekday_4     731 non-null    int64  \n",
      " 25  weekday_5     731 non-null    int64  \n",
      " 26  weekday_6     731 non-null    int64  \n",
      " 27  temp          731 non-null    float64\n",
      " 28  atemp         731 non-null    float64\n",
      " 29  hum           731 non-null    float64\n",
      " 30  windspeed     731 non-null    float64\n",
      " 31  holiday       731 non-null    int64  \n",
      " 32  workingday    731 non-null    int64  \n",
      " 33  yr            731 non-null    int64  \n",
      " 34  cnt           731 non-null    int64  \n",
      "dtypes: float64(4), int64(31)\n",
      "memory usage: 200.0 KB\n"
     ]
    }
   ],
   "source": [
    "df.info()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 数据拆分"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "df.drop(['instant'],axis=1,inplace=True)\n",
    "y = df['cnt']\n",
    "# y = np.log1p(y)\n",
    "x = df.drop(['cnt'],axis=1)\n",
    "from sklearn.model_selection import train_test_split\n",
    "from sklearn.metrics import mean_squared_error,r2_score\n",
    "x_train,x_test,y_train,y_test = train_test_split(x,y,random_state=32,test_size=0.2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 最小二乘线性回归模型"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.linear_model import LinearRegression\n",
    "lr = LinearRegression()\n",
    "lr.fit(x_train,y_train)\n",
    "y_test_pred_lr = lr.predict(x_test)\n",
    "#使用RMSE作为评测标准\n",
    "MSE_lr = mean_squared_error(y_test,y_test_pred_lr)\n",
    "RMSE_lr = np.sqrt(MSE_lr)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 岭回归模型"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.linear_model import RidgeCV\n",
    "alphas = [0.01,0.1 ,1 ,10,100]\n",
    "ridge = RidgeCV(alphas=alphas,store_cv_values=True)\n",
    "ridge.fit(x_train,y_train)\n",
    "y_test_rped_ridge = ridge.predict(x_test)\n",
    "MSE_ridge = mean_squared_error(y_test,y_test_rped_ridge)\n",
    "RMSE_ridge = np.sqrt(MSE_ridge)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Lasso模型"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.linear_model import LassoCV\n",
    "lasso = LassoCV()\n",
    "lasso.fit(x_train,y_train)\n",
    "y_test_pred_lasso = lasso.predict(x_test)\n",
    "MSE_lasso = mean_squared_error(y_test,y_test_pred_lasso)\n",
    "RMSE_lasso = np.sqrt(MSE_lasso)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "LR result:710.3714942647583\n",
      "Ridge result:698.0141008948899\n",
      "Lasso result:697.1033538714764\n"
     ]
    }
   ],
   "source": [
    "print(f\"LR result:{RMSE_lr}\")\n",
    "print(f\"Ridge result:{RMSE_ridge}\")\n",
    "print(f\"Lasso result:{RMSE_lasso}\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 根据RMSE标准，最小二乘线性模型的RMSE数值与岭回归的RMSE数值非常接近；而Lasso的RMSE相对而言偏高一点。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "LR M:[-5.77053253e+15 -5.77053253e+15 -5.77053253e+15 -5.77053253e+15\n",
      "  2.11212999e+16  2.11212999e+16  2.11212999e+16  2.11212999e+16\n",
      "  2.11212999e+16  2.11212999e+16  2.11212999e+16  2.11212999e+16\n",
      "  2.11212999e+16  2.11212999e+16  2.11212999e+16  2.11212999e+16\n",
      " -1.15761004e+16 -1.15761004e+16 -1.15761004e+16 -2.04452743e+16\n",
      " -5.01510025e+15 -5.01510025e+15 -5.01510025e+15 -5.01510025e+15\n",
      " -5.01510025e+15 -2.04452743e+16  2.78822518e+03  9.36021459e+02\n",
      " -1.79481585e+03 -1.49480965e+03 -1.54301741e+16 -1.54301741e+16\n",
      "  2.01430969e+03]\n",
      "Ridge M:[ -886.45387829    73.36594939    49.39779405   763.69013485\n",
      "  -449.98294879  -228.069138     288.51522352   133.79109538\n",
      "   384.43691317   235.1447974   -267.59059614   107.26612128\n",
      "   600.4069847    168.61922246  -495.90298926  -476.63468572\n",
      "   774.17819267   306.79020495 -1080.96839762  -103.1417841\n",
      "  -153.97676236   -87.14731535   -45.14995787   -27.76902041\n",
      "   131.14772156   286.03711852  1834.66469485  1535.41348279\n",
      " -1438.34958509 -1327.86281733  -437.27150179   254.37616736\n",
      "  2021.6696344 ]\n",
      "Lasso M:[-1.06922909e+03  1.21170724e+01 -8.30163216e+01  5.77967947e+02\n",
      " -3.49874258e+02 -1.38160093e+02  2.60356288e+02  0.00000000e+00\n",
      "  2.12871433e+02  4.89583085e+01 -3.90790809e+02 -0.00000000e+00\n",
      "  5.05288181e+02  1.53976596e+02 -4.29085688e+02 -3.94529559e+02\n",
      "  4.42074682e+02 -0.00000000e+00 -1.35600633e+03 -2.78910873e+02\n",
      " -8.96586441e+01 -1.73203896e+01  0.00000000e+00  5.72143751e+00\n",
      "  1.60218518e+02  7.68265339e+01  2.68159095e+03  9.20743083e+02\n",
      " -1.53466774e+03 -1.35453157e+03 -6.41745787e+02  1.79062630e+00\n",
      "  2.01736231e+03]\n"
     ]
    }
   ],
   "source": [
    "print(f\"LR M:{lr.coef_}\")\n",
    "print(f\"Ridge M:{ridge.coef_}\")\n",
    "print(f\"Lasso M:{lasso.coef_}\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 根据三个模型的系数矩阵可以了解到，Lasso的系数矩阵是比较稀疏的。同时，最小二乘模型的系数偏大，这将导致模型的不稳定；反观ridge和lasso系数基本没有过大。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Ridge alpha:1.0\n",
      "Lasso alpha:2.3970923024890207\n"
     ]
    }
   ],
   "source": [
    "print(f\"Ridge alpha:{ridge.alpha_}\")\n",
    "print(f\"Lasso alpha:{lasso.alpha_}\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2.3970923024890207"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "lasso.alpha_ "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "mse_cv = np.mean(lasso.mse_path_,axis=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0x202e8703e80>]"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAZAAAAD4CAYAAADCb7BPAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAAgAElEQVR4nO3de3ydVZ3v8c8vSZOWJr2kSUrbtPQKbbm00FDKReRmqegRHMGpovSlKKg4ypy5AM6cAZGZkRmVczgqHhCHgmjpoA6MiligCEhpm16gV2jovQ25NEmbXnLb+3f+2CuwG0KapkmevZPv+/XaZGfttdb+7QD55nnW2s82d0dEROR4ZURdgIiIpCcFiIiIdIkCREREukQBIiIiXaIAERGRLsmKuoDeVFBQ4OPHj4+6DBGRtLJq1apqdy9s296vAmT8+PGUlpZGXYaISFoxsx3ttesUloiIdIkCREREukQBIiIiXaIAERGRLlGAiIhIlyhARESkSxQgIiLSJQoQE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NbJOZbTCzb0Zd04kws4FmtsLMXg+v59tR19QdzCzTzNaY2W+jrqU7mNl2M1tnZmvNrDTqek6UmQ0zsyfNbHP4f+n8SOvRGkhqMrOLgYPAo+5+RtT1nCgzGwWMcvfVZpYHrAKucfeNEZfWJZb4EPrB7n7QzAYArwDfdPfXIi7thJjZ/wRKgCHu/vGo6zlRZrYdKHH3PvFGQjNbCLzs7j81s2zgJHevi6oeHYGkKHd/CaiJuo7u4u7l7r463K8HNgFjoq2q6zzhYPh2QLil9V9jZlYMfAz4adS1yPuZ2RDgYuBhAHdvijI8QAEiETCz8cDZwPJoKzkx4XTPWqASWOLuaf16gP8N/D0Qj7qQbuTAH81slZndFHUxJ2giUAX8RzjN+FMzGxxlQQoQ6VVmlgv8CrjV3Q9EXc+JcPeYu88EioHZZpa2pxrN7ONApbuvirqWbnahu58DfBS4JZwaTldZwDnAA+5+NnAIuD3KghQg0mvCWsGvgMfd/ddR19NdwmmEF4F5EZdyIi4EPhHWDBYBl5nZz6Mt6cS5+97wtRL4DTA72opOyG5gd9KR7pMkAiUyChDpFWHR+WFgk7v/IOp6TpSZFZrZsHB/EHAFsDnaqrrO3e9w92J3Hw/MB15w989FXNYJMbPBYcMG4VTPXCBtdzW6+zvALjM7LTRdDkS6CSUryieXD2ZmvwQuAQrMbDdwp7s/HG1VJ+RC4PPAurBuAPAtd/99hDWdiFHAQjPLJPGH2GJ37xNbX/uQkcBvEn+7kAX8wt3/EG1JJ+yvgMfDDqytwBeiLEbbeEVEpEt0CktERLpEASIiIl2iABERkS5RgIiISJcoQEREpEsUICIi0iUKEBER6ZL/D/22W16DT1bNAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "from matplotlib import pyplot as plt\n",
    "plt.plot(np.log1p(lasso.alphas_),mse_cv)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([516.43788117, 481.63169644, 449.17133206, 418.8986876 ,\n",
       "       390.66631806, 364.33671574, 339.78164049, 316.88149513,\n",
       "       295.52474293, 275.60736434, 257.03235041, 239.70923025,\n",
       "       223.55363041, 208.48686393, 194.43554708, 181.33124196,\n",
       "       169.11012315, 157.71266684, 147.08336094, 137.17043468,\n",
       "       127.92560648, 119.30384875, 111.26316864, 103.76440346,\n",
       "        96.77102996,  90.24898642,  84.16650679,  78.49396592,\n",
       "        73.20373533,  68.27004857,  63.66887579,  59.37780666,\n",
       "        55.37594122,  51.64378812,  48.16316964,  44.91713321,\n",
       "        41.88986876,  39.06663181,  36.43367157,  33.97816405,\n",
       "        31.68814951,  29.55247429,  27.56073643,  25.70323504,\n",
       "        23.97092302,  22.35536304,  20.84868639,  19.44355471,\n",
       "        18.1331242 ,  16.91101231,  15.77126668,  14.70833609,\n",
       "        13.71704347,  12.79256065,  11.93038488,  11.12631686,\n",
       "        10.37644035,   9.677103  ,   9.02489864,   8.41665068,\n",
       "         7.84939659,   7.32037353,   6.82700486,   6.36688758,\n",
       "         5.93778067,   5.53759412,   5.16437881,   4.81631696,\n",
       "         4.49171332,   4.18898688,   3.90666318,   3.64336716,\n",
       "         3.3978164 ,   3.16881495,   2.95524743,   2.75607364,\n",
       "         2.5703235 ,   2.3970923 ,   2.2355363 ,   2.08486864,\n",
       "         1.94435547,   1.81331242,   1.69110123,   1.57712667,\n",
       "         1.47083361,   1.37170435,   1.27925606,   1.19303849,\n",
       "         1.11263169,   1.03764403,   0.9677103 ,   0.90248986,\n",
       "         0.84166507,   0.78493966,   0.73203735,   0.68270049,\n",
       "         0.63668876,   0.59377807,   0.55375941,   0.51643788])"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "lasso.alphas_\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(100,)"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.log1p(lasso.alphas_).shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(100,)"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mse_cv.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "learn",
   "language": "python",
   "name": "py3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
